#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <unordered_set>

using namespace std;

class Solution {
public:
    int canBeTypedWords(string text, string brokenLetters) {
        unordered_set<char> S;
        for (char c : brokenLetters)
            S.insert(c);
        int ans = 0;
        for (int i = 0; i < text.size(); i++)
        {
            int pos = text.find(' ');
            string s = text.substr(i, pos - i);
            bool flag = 1;
            for (char c : s)
                if (S.count(c))
                    flag = 0;
            if (flag) ans++;
            text = text.substr(pos + 1, text.size() - pos - 1);
            i = pos;
        }
        return ans;
    }
};